package com.base.core.service;

import java.util.List;

import com.base.core.dao.IBaseDao;
import com.base.core.dao.BaseDao;
import com.base.core.domain.BaseDomain;


public class BaseService implements IBaseService {

	private IBaseDao baseDao;

	public IBaseDao getBaseDao() {
		return baseDao;
	}

	public void updateDomain(BaseDomain domain, String sqlMap){
		 baseDao.updateDomain(domain, sqlMap);
	}
	
	public void setBaseDao(IBaseDao basedao) {
		this.baseDao = basedao;
	}

	public int insert(BaseDomain domain, String sqlMap) {

		return baseDao.insertDomain(domain, sqlMap);
	}
	
	
	public List query(BaseDomain domain) {
		return baseDao.queryDomain(domain);
	}

	public int saveEntity(BaseDomain domain) {
		baseDao.insertDomain(domain);
		return 1;
	}

	public void beginTransaction() {
		try {
			((BaseDao) baseDao).getSqlSession().commit(false);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void rollbackTransaction() {
		try {
			((BaseDao) baseDao).getSqlSession().rollback();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void commitTransaction() {
		try {
			((BaseDao) baseDao).getSqlSession().commit(true);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
